#include "ExitDialog.h"
#include "cocos2d.h"

USING_NS_CC;

bool ExitDlg::onInitDialog()
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	CCSprite *t_pSprite=CCSprite::create("HelloWorld.png");
	t_pSprite->setPosition(ccp(winSize.width/2,winSize.height/2));
	t_pSprite->setScale(0.5);
	this->addChild(t_pSprite);

    CCMenuItemFont *okMenuItem = CCMenuItemFont::create("OK", this, menu_selector(ExitDlg::okMenuItemCallback));
    okMenuItem->setPosition(ccp(t_pSprite->getContentSize().width / 3, t_pSprite->getContentSize().height/2));

    CCMenuItemFont *cancelMenuItem = CCMenuItemFont::create("Cancel", this, menu_selector(ExitDlg::cancelMenuItemCallback));
    cancelMenuItem->setPosition(ccp(t_pSprite->getContentSize().width / 3*2 , t_pSprite->getContentSize().height / 2));

    pushMenu(okMenuItem);
    pushMenu(cancelMenuItem);

//    setColor(ccc3(255,0,0));
//    setOpacity(128);
    return true;
}

void ExitDlg::okMenuItemCallback(CCObject *obj)
{
    CCDirector::sharedDirector()->end();
}

void ExitDlg::cancelMenuItemCallback(CCObject *obj)
{
    removeFromParentAndCleanup(true);
}